//
//  GQDistribuerLocationController.m
//  GuQu
//
//  Created by HELIUM STAR on 15/5/13.
//  Copyright (c) 2015年 HELIUM STAR. All rights reserved.
//

#import "GQDistribuerLocationController.h"
#import "GQDistributeLocationCell.h"
#import "GQDistributeSelecteLabelController.h"

@interface GQDistribuerLocationController () <UISearchBarDelegate, UITableViewDataSource ,UITableViewDelegate>

@property (weak, nonatomic) UISearchBar *searchBar;

@end

@implementation GQDistribuerLocationController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageWithOriginalName:@"distribute_back"] style:UIBarButtonItemStylePlain target:self action:@selector(backToPre)];
    
    UIButton *rightItem = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 50, 20)];
    [rightItem setTitle:@"删除" forState:UIControlStateNormal];
    [rightItem setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    rightItem.titleLabel.font = [UIFont systemFontOfSize:14];
    
    self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightItem];
    
    
    self.title = @"搜索位置";
    [self setUpSearbar];
    [self setUpLocationList];
}

- (void)backToPre
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)setUpSearbar
{
    UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, kNavigatationBarHeight, self.view.width, 44)];
    searchBar.placeholder = @"搜索附近位置";
    self.searchBar = searchBar;
    [self.view addSubview:searchBar];
}

- (void)setUpLocationList
{
    UITableView *tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(self.searchBar.frame), self.view.width, self.view.height - kNavigatationBarHeight - self.searchBar.height)];
    tableView.separatorInset = UIEdgeInsetsMake(0, 20, 0, 20);
    tableView.delegate = self;
    tableView.dataSource = self;
    [self.view addSubview:tableView];
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *flag = @"flag";
    GQDistributeLocationCell *cell = [tableView dequeueReusableCellWithIdentifier:flag];
    if (cell == nil) {
        cell = [[GQDistributeLocationCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:flag];
    }
    return cell;
}

@end
